Allow passing a color matrix when rendering icons
authorMatthias Clasen <mclasen@redhat.com>
Mon, 23 Oct 2017 09:42:23 +0000 (11:42 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 23 Oct 2017 09:44:52 +0000 (11:44 +0200)
This will be used for symbolic icons.
Update all callers.

gtk/gtkiconhelper.c
gtk/gtkrendericon.c
gtk/gtkrendericonprivate.h
gtk/gtksnapshot.c

index 4ea8428cdbbd25fb05c2548f84257f4c0db99c66..5d47954536f55464bf8b8614f5961985efcf23db 100644 (file)
@@ -802,7 +802,8 @@ gtk_icon_helper_snapshot (GtkIconHelper *self,
   gtk_css_style_snapshot_icon_texture (style,
                                        snapshot,
                                        texture,
-                                       gtk_widget_get_scale_factor (self->owner));
+                                       gtk_widget_get_scale_factor (self->owner),
+                                       NULL, NULL);
 }
 
 gboolean
index e38c2aa92d4cb9a6094b583fd7766ed9bd41e6c0..b028d7722e604231852a93773b5c1f6711469696 100644 (file)
@@ -271,10 +271,12 @@ gtk_css_style_render_icon_get_extents (GtkCssStyle  *style,
 }
 
 void
-gtk_css_style_snapshot_icon_texture (GtkCssStyle *style,
-                                     GtkSnapshot *snapshot,
-                                     GskTexture  *texture,
-                                     double       texture_scale)
+gtk_css_style_snapshot_icon_texture (GtkCssStyle       *style,
+                                     GtkSnapshot       *snapshot,
+                                     GskTexture        *texture,
+                                     double             texture_scale,
+                                     graphene_matrix_t *color_matrix,
+                                     graphene_vec4_t *  color_offset)
 {
   const GtkCssValue *shadows_value, *transform_value, *filter_value;
   graphene_matrix_t transform_matrix;
@@ -307,6 +309,9 @@ gtk_css_style_snapshot_icon_texture (GtkCssStyle *style,
       gtk_snapshot_push_shadow (snapshot, shadows, n_shadows, "IconShadow<%zu>", n_shadows);
     }
 
+  if (color_matrix)
+    gtk_snapshot_push_color_matrix (snapshot, color_matrix, color_offset, "Recoloring Icon");
+
   if (graphene_matrix_is_identity (&transform_matrix))
     {
       graphene_rect_init (&bounds, 0, 0, width, height);
@@ -331,6 +336,9 @@ gtk_css_style_snapshot_icon_texture (GtkCssStyle *style,
       gtk_snapshot_pop (snapshot);
     }
 
+  if (color_matrix)
+    gtk_snapshot_pop (snapshot);
+
   if (n_shadows > 0)
     gtk_snapshot_pop (snapshot);
   
index 2ab38f76990763ee8c85f11a8b3f0afb4d9df255..29b81c4dbb78867e2da74a7dc01901cd5dca961b 100644 (file)
@@ -50,7 +50,9 @@ void    gtk_css_style_render_icon_surface       (GtkCssStyle            *style,
 void    gtk_css_style_snapshot_icon_texture     (GtkCssStyle            *style,
                                                  GtkSnapshot            *snapshot,
                                                  GskTexture             *texture,
-                                                 double                  texture_scale);
+                                                 double                  texture_scale,
+                                                 graphene_matrix_t *     color_matrix,
+                                                 graphene_vec4_t *       color_offset);
 
 void    gtk_css_style_render_icon_get_extents   (GtkCssStyle            *style,
                                                  GdkRectangle           *extents,
index 44136679121b75858d1accd1bd0dc8b228cd457c..d9d463a99c465162acd19d7733b2f0d6bb2c6baf 100644 (file)
@@ -1517,7 +1517,8 @@ gtk_snapshot_render_icon (GtkSnapshot     *snapshot,
   gtk_css_style_snapshot_icon_texture (gtk_style_context_lookup_style (context),
                                        snapshot,
                                        texture,
-                                       1);
+                                       1,
+                                       NULL, NULL);
   gtk_snapshot_offset (snapshot, -x, -y);
   g_object_unref (texture);
 }